<?php
/**
 * Model providing vendor-specific implementation of SQLServer. Needs to be extended by a class implementing an individual server your application connects to.
 * 
 * Example of an implementation:
class TestServer extends MySQLServer {
	private static $objDataSource;
	private static $instance;
	
	// sets data source
	public static function setDataSource($objDataSource) {
		self::$objDataSource = $objDataSource;
	}
	
	// connects to SQL server
	private function __construct() {
		if(!self::$objDataSource) throw new SQLException("Data source not set!");
		$this->connect(self::$objDataSource);
	}
	
	// singleton insuring only one instance is created for this class
	public static function getInstance() {
		if(!self::$instance) {
			self::$instance = new TestServer();
		}
		
		return self::$instance;
	}
}
 */
abstract class MySQLServer extends SQLServer {
	/**
	 * (non-PHPdoc)
	 * @see SQLServer::getDatabases()
	 */
	public function getDatabases() {
		$objQuery = new MySQLServerQuery();
		return SQLResults::toColumn($this->executeStatement($objQuery->getDatabases()));
	}
	
	/**
	 * Gets list of processes running on server
	 * 
	 * @return array
	 */
	public function getProcesses() {
		$objQuery = new MySQLServerQuery();
		return SQLResults::toList($this->executeStatement($objQuery->getProcesses()));
	}

	/**
	 * Kills a running process on server.
	 * 
	 * @param integer $intProcessId
	 * @return void
	 */
	public function killProcess($intProcessId) {
		$objQuery = new MySQLServerQuery();
		$this->executeStatement($objQuery->killProcess($intProcessId));
	}
}